@extends('shop::layouts.master')
@section('title')
    {{$title}}
@endsection
@section('tab')
    <form class="layui-form">
        <div class="goods_fax">
            <div class="layui-row">
                <div class="layui-tab layui-tab-brief" lay-filter="form_add">
                    <div class="layui-tab-content">
                        <input type="hidden" name="id" value="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">版本号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="edition" value="" lay-verify="required" autocomplete="off"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型</label>
                            <div class="layui-input-inline">
                                <select name="type" lay-filter="form_type">
                                    @foreach($arr_app_type as $key=>$value)
                                        <option value="{{$key}}">{{$value}}</option>
                                    @endforeach
                                </select>
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">是否强制更新</label>
                            <div class="layui-input-inline">
                                <select name="is_force" lay-filter="form_is_force">
                                    @foreach($arr_is_force as $key=>$value)
                                        <option value="{{$key}}">{{$value}}</option>
                                    @endforeach
                                </select>
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">安装包</label>
                            <div class="layui-input-inline">
                                <input type="text" name="url" id="url" autocomplete="off"  class="layui-input">

                                {{--                                <textarea name="url" id="url" style="height:80px; width: 100%"></textarea>--}}
                                {{--<input type="text" name="url" id="url" value="{{$data['url']}}" lay-verify="required" autocomplete="off"  class="layui-input">--}}
                            </div>
                            <button type="button" class="layui-btn" id="upFile"><i class="layui-icon"></i>上传文件</button>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">版本更新说明</label>
                            <div class="layui-input-inline">
                                <textarea name="content" cols="50" rows="5"></textarea>

                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label for="L_repass" class="layui-form-label"></label>
                            <button class="layui-btn" lay-filter="add" lay-submit="">提交</button>
                            <input type="hidden" id="L_id" name="id">
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>
@endsection

@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery','upload'], function () {
            $ = layui.jquery;
            var form = layui.form,
                upload = layui.upload,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    url: js_url('admin_app_app_add_do'),
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6}, function () {
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 600, icon: 5});
                        }
                    }
                });
                return false;
            });

            //多图片上传
            upload.render({
                elem: '#upFile'
                , url: 'admin-upload-file'
                ,accept: 'file' //普通文件
                ,done: function(res){
                    if (res.code === 0) {
                        layer.msg(res.msg, {}, function () {
                            $('#url').val(res.url);
                        });
                    } else {
                        layer.msg(res.msg, {});
                    }
                }
            });

        });
    </script>
@endsection




